package com.cus.tom.transfer.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.cus.tom.transfer.App;
import com.cus.tom.transfer.R;
import com.cus.tom.transfer.frag.EmptyFrag;
import com.cus.tom.transfer.frag.RecordAppFragment;
import com.cus.tom.transfer.frag.RecordAudioFragment;
import com.cus.tom.transfer.frag.RecordImgFragment;
import com.cus.tom.transfer.frag.RecordInfoFragment;
import com.cus.tom.transfer.frag.RecordVideoFragment;

public class RecordAdapter extends FragmentStatePagerAdapter {

    final String[] ss = App.getApp().getResources().getStringArray(R.array.title_record);
    int type;

    public RecordAdapter(@NonNull FragmentManager fm, int type) {
        super(fm);
        this.type = type;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return new RecordImgFragment(type);
            case 1:
                return new RecordVideoFragment(type);
            case 2:
                return new RecordAudioFragment(type);
            case 3:
                return new RecordAppFragment(type);
            case 4:
                return new RecordInfoFragment(type);
            default:
                return new EmptyFrag();
        }
    }

    @Override
    public int getCount() {
        return ss.length;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return ss[position];
    }
}
